const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin');
var ProgressBarPlugin = require('progress-bar-webpack-plugin');
const path = require('path');
module.exports = {
    entry: __dirname + "/src/app.js",
    output: {
        path: path.resolve(process.cwd(), 'dist'),
        filename: "scripts/[name].js"
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ExtractTextPlugin.extract({
                  fallback: "style-loader",
                  use: 'css-loader'
                })
            }
        ]
    },
    plugins: [
        new webpack.BannerPlugin('版权所有，翻版必究🐶'),
        new HtmlWebpackPlugin({template: 'index.html'}),
        new CleanWebpackPlugin(),
        new ProgressBarPlugin(),
        new ExtractTextPlugin({
            filename:  (getPath) => {
              return getPath('css/[name].css').replace('css/js', 'css');
            },
            allChunks: true
        })
    ]
};
